home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)Z / (A)Z9.ADF / Joke / joke.c < prev    next >
C/C++ Source or Header  |  1989-07-05  |  4KB  |  143 lines

  1.  
  2. /* A lightbulb joke making program.  This isn't AI, but then, what is? */
  3. /* Ported to the Amiga with no changes by John Foust */
  4.  
  5. #include <time.h>
  6. #include <stdio.h>
  7.  
  8. #define MAXT 20
  9.  
  10. char plist[100][32], alist[100][32], tlist[100][32];
  11.  
  12.  
  13. long random() {
  14. long foo;
  15.     foo = rand() * rand();
  16.     if (foo<0) {
  17.         foo = (-foo);
  18.     }
  19.     return( foo );
  20. }
  21.  
  22.  
  23. main(argc,argv)
  24. int argc;
  25. char *argv[];
  26. {
  27. long ltime;
  28. int people, action, things, total, first, rest, np, na, nt;
  29.  
  30.     np = 0;
  31.     strcpy(plist[np++],"<ethnics>");
  32.     strcpy(plist[np++],"Doctors");
  33.     strcpy(plist[np++],"JAPs");
  34.     strcpy(plist[np++],"Lawyers");
  35.     strcpy(plist[np++],"Martians");
  36.     strcpy(plist[np++],"Newfoundlanders");
  37.     strcpy(plist[np++],"Programmers");
  38.     strcpy(plist[np++],"Students");
  39.     strcpy(plist[np++],"Yuppies");
  40.     strcpy(plist[np++],"Zen Masters");
  41.     strcpy(plist[np++],"Politicians");
  42.     strcpy(plist[np++],"DEC repairmen");
  43.     strcpy(plist[np++],"Russians");
  44.     strcpy(plist[np++],"Americans");
  45.     strcpy(plist[np++],"Canadians");
  46.     strcpy(plist[np++],"Nuns");
  47.     strcpy(plist[np++],"Priests");
  48.     strcpy(plist[np++],"Professors");
  49.     strcpy(plist[np++],"Californians");
  50.     
  51.  
  52.     na = 0;
  53.     strcpy(alist[na++],"build");
  54.     strcpy(alist[na++],"call");
  55.     strcpy(alist[na++],"change");
  56.     strcpy(alist[na++],"cook");
  57.     strcpy(alist[na++],"eat");
  58.     strcpy(alist[na++],"fix");
  59.     strcpy(alist[na++],"fly");
  60.     strcpy(alist[na++],"make");
  61.     strcpy(alist[na++],"move");
  62.     strcpy(alist[na++],"play");
  63.     strcpy(alist[na++],"watch");
  64.     strcpy(alist[na++],"tell");
  65.     strcpy(alist[na++],"love");
  66.     strcpy(alist[na++],"kill");
  67.     strcpy(alist[na++],"pick");
  68.     strcpy(alist[na++],"climb");
  69.     strcpy(alist[na++],"write");
  70.     strcpy(alist[na++],"save");
  71.     strcpy(alist[na++],"shop");
  72.     strcpy(alist[na++],"find");
  73.     
  74.     
  75.     nt = 0;
  76.     strcpy(tlist[nt++],"VAX");
  77.     strcpy(tlist[nt++],"IBM PC");
  78.     strcpy(tlist[nt++],"telephone");
  79.     strcpy(tlist[nt++],"subroutine");
  80.     strcpy(tlist[nt++],"house");
  81.     strcpy(tlist[nt++],"thesis");
  82.     strcpy(tlist[nt++],"nose");
  83.     strcpy(tlist[nt++],"Grizzly Bear");
  84.     strcpy(tlist[nt++],"light bulb");
  85.     strcpy(tlist[nt++],"birthday cake");
  86.     strcpy(tlist[nt++],"flat tire");
  87.     strcpy(tlist[nt++],"trumpet");
  88.     strcpy(tlist[nt++],"movie");
  89.     strcpy(tlist[nt++],"airplane");
  90.     strcpy(tlist[nt++],"book");
  91.     strcpy(tlist[nt++],"TV show");
  92.     strcpy(tlist[nt++],"Lisp program");
  93.     strcpy(tlist[nt++],"C program");
  94.     strcpy(tlist[nt++],"Fortran program");
  95.     strcpy(tlist[nt++],"cat");
  96.     strcpy(tlist[nt++],"hockey game");
  97.     strcpy(tlist[nt++],"dog");
  98.     strcpy(tlist[nt++],"fish");
  99.     strcpy(tlist[nt++],"UNIX system");
  100.     strcpy(tlist[nt++],"video game");
  101.     strcpy(tlist[nt++],"baseball bat");
  102.     strcpy(tlist[nt++],"Lightbulb joke");
  103.     strcpy(tlist[nt++],"frog");
  104.     strcpy(tlist[nt++],"compiler");
  105.     strcpy(tlist[nt++],"nuclear bomb");
  106.     strcpy(tlist[nt++],"cruise missile");
  107.     strcpy(tlist[nt++],"tree");
  108.     strcpy(tlist[nt++],"whale");
  109.  
  110.     srand( (int)time(<ime));
  111.     
  112.     people = random() % np;
  113.     action = random() % na;
  114.     things = random() % nt;
  115.     
  116.     printf ("How many %s does it take to %s a %s?\n",
  117.         plist[people],alist[action],tlist[things]);
  118.  
  119.     total = 1 + (random() % MAXT);
  120.     first = 1 + (random() % total);
  121.     rest  = total - first;
  122.     
  123.     action = random() % na;
  124.     things = random() % nt;
  125.  
  126.     if (total == 1) {
  127.         printf ("Just one. Why should it take any more?\n");
  128.     }
  129.     else {
  130.     printf ("%d. %d to %s the %s, ",
  131.         total,first,alist[action],tlist[things]);
  132.  
  133.     action = random() % na;
  134.     things = random() % nt;
  135.  
  136.     printf ("and %d to %s the %s.\n",
  137.                 rest,alist[action],tlist[things]);
  138.     }
  139.     
  140.     exit(0);
  141. }
  142.  
  143.